import React from "react";
import { BrowserRouter, useRoutes } from 'react-router-dom'
const Layout = React.lazy(() => import("../views/layout"));
const PersonAdd = React.lazy(() => import("../views/personAdd"));
const PersonList = React.lazy(() => import("../views/personList"));
const PersonCheck = React.lazy(() => import("../views/personCheck"));
const PersonDetail = React.lazy(() => import("../views/personDetail"));
const Car = React.lazy(() => import("../views/car"));

const routes = [
  {
    path: "/",
    element: <Layout></Layout>,
    children: [
      {
        path: "/",
        element: <PersonCheck></PersonCheck>,
      },
      {
        path: "/person/list",
        element: <PersonList></PersonList>,
      },
      {
        path: "/person/add",
        element: <PersonAdd></PersonAdd>,
      },
      {
        path: "/person/:id",
        element: <PersonDetail></PersonDetail>,
      },
      {
        path: "/car",
        element: <Car></Car>,
      },
    ],
  },
];

const Router = () => {
	const App = () => useRoutes(routes)
	return (
		<BrowserRouter>
			<App></App>
		</BrowserRouter>
	)
}

export default Router
